import axios from 'axios'

const instance = axios.create({
  baseURL:'https://www.young1024.com:3002',
  method:'POST'
})

instance.interceptors.request.use(function(config){
  // console.log(config)
  // config.data = 'type=NBA'
  // type=NBA&age=18&name=young
  // console.log(config.data)

  let prams = ''
  for(var i in config.data){
    // console.log(i)
    // console.log(config.data[i])

    prams += i+'='+config.data[i]+'&'
  }

  // console.log(prams)

  prams = prams.slice(0,-1)
  // console.log(prams)
  
  config.data = prams

  return config;
})


instance.interceptors.response.use(function(data){
  // console.log(data)

  if(data.data.status==='success'){
    return data.data.data
  }else{
    return data
  }
})






export default instance;